package jjn.effective_java.chapter6.item34;

/**
 * @author Jiang Jining
 * @since 2023-04-26 23:03
 */
public enum OperationV2 {
    PLUS {
        public double apply(double x, double y) {
            return x + y;
        }
    },
    
    MINUS {
        public double apply(double x, double y) {
            return x - y;
        }
    },
    TIMES {
        public double apply(double x, double y) {
            return x * y;
        }
    },
    
    DIVIDE {
        public double apply(double x, double y) {
            return x / y;
        }
    };
    
    /**
     * 强制每个枚举实例实现接口.
     *
     * @param x x
     * @param y y
     * @return result
     */
    public abstract double apply(double x, double y);
}
